package	com.sdry.service.impl.tdd.refunds;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sdry.mapper.llm.CancellingStockDetailMapper;
import com.sdry.mapper.llm.CancellingStockMapper;
import com.sdry.mapper.tdd.refunds.CancellingStocksDetailPiLiangMapper;
import com.sdry.model.llm.LlmCancellingStocksDetail;
import com.sdry.model.lz.Materiel;
import com.sdry.service.tdd.refunds.CancellingStocksDetailPiLiangService;
/**
 *
 *@ClassName: CancellingStocksDetailPiLiangService
 *@Description: 退货单——批次退货
 *@Author tdd
 *@Date 2019-10-17 18:27:11
 *@version 1.0
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class CancellingStocksDetailPiLiangServiceImpl implements CancellingStocksDetailPiLiangService {
	@Resource CancellingStocksDetailPiLiangMapper CancellingStocksDetailPiLiangMapper;
	@Resource CancellingStockDetailMapper cancellingStockDetailMapper;
	@Resource CancellingStockMapper cancellingStockMapper;
	/** 
	 * 根据主键id查询实体
	 * @param id 主键id
	 * @return 实体
	*/
	public LlmCancellingStocksDetail queryById(Long id) {
		return CancellingStocksDetailPiLiangMapper.queryById(id);
	}
	/** 
	 * 插入返回id
	 * @param param 实体条件
	 * @return 主键id
	*/
	public Long insert(LlmCancellingStocksDetail param) {
		return CancellingStocksDetailPiLiangMapper.insert(param);
	}
	/** 
	 * 根据主键更新 返回影响行数
	 * @param param 实体条件
	 * @return 影响行数
	*/
	public Integer update(LlmCancellingStocksDetail param) {
		return CancellingStocksDetailPiLiangMapper.update(param);
	}
	/** 
	 * 根据主键拼接的字符串删除返回影响行数
	 * @param ids 主键拼接的字符串
	 * @return 影响行数
	*/
	public Integer delete(String ids) {
		return CancellingStocksDetailPiLiangMapper.delete(ids);
	}
	/** 
	 * 条件查询所有
	 * @param param 实体条件
	 * @return 实体集合
	*/
	public List<LlmCancellingStocksDetail> queryAllByMution(LlmCancellingStocksDetail param){
		List<LlmCancellingStocksDetail> list = CancellingStocksDetailPiLiangMapper.queryAllByMution(param);
		if(list.size() > 0){
			for(LlmCancellingStocksDetail detail : list){
				if(detail.getMaterialId() != null && !"".equals(detail.getMaterialId())){
					Materiel materiel = cancellingStockMapper.getMaterielByMid(detail.getMaterialId());
					if(materiel != null){
						detail.setMateriel_name(materiel.getMateriel_name());
						detail.setMateriel(materiel);
					}
				}
			}
		}
		return list;
	}
	/** 
	 * 条件分页查询
	 * @param param 实体条件
	 * @return 实体集合
	*/
	public List<LlmCancellingStocksDetail> findPageByMution(LlmCancellingStocksDetail param){
		return CancellingStocksDetailPiLiangMapper.findPageByMution(param);
	}
	/** 
	 * 条件查询记录数
	 * @param param 实体条件
	 * @return 实体集合
	*/
	public Integer selectCountByMution(LlmCancellingStocksDetail param){
		return CancellingStocksDetailPiLiangMapper.selectCountByMution(param);
	}
}
